package org.qloudgen.borg.pages.dataGridView;

import java.util.HashMap;
import java.util.Map;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

@SuppressWarnings("unchecked")
public class QueryCellPopulator<T>  implements ICellPopulator<T> {

	private static final long serialVersionUID = 1L;
	
	final String property;
	
	public QueryCellPopulator(String property){
		this.property = property;
	}
	
	public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, IModel<T> rowModel)
	  {
		
		// get cell content
		Map<String, String> data =  (HashMap<String, String>) rowModel.getObject();
		String content = data.get(this.property);
		
		//数据显示和样式处理
		cellItem.add(new Component[] { new Label(componentId,content)});
		    	
	}

	@Override
	public void detach() {}
	
}